<!DOCTYPE html>
<html lang="en" xmlns:th="https://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>[[${title}]]</title>
    <style>
        body {
            background-color: #cccccc;
        }

        h1 {
            text-align: center;
        }

        form {
            width: 500px;
            margin: 0 auto;
            margin-top: 200px;
            padding: 60px;
            background-color: white;
            border-radius: 10px;
            box-shadow: 5px 5px 10px 0 rgba(0, 0, 0, 0.5);
        }

        input, select {
            padding-top: 10px;
            padding-bottom: 10px;
            margin-top: 10px;
            margin-bottom: 10px;
            width: calc(100% - 60px);
        }

        input[type = 'radio'] {
            width: 20px;
        }

        input[type = 'submit'] {
            width: 100%;
            background-color: #6abb91;
        }

        span {
            display: inline-block;
            width: 50px;
        }
    </style>
</head>
<body>
<!--显示 新增 或 编辑-->
<h1>[[${title}]]</h1>
<form th:action="@{/student/saveStudent}" method="post">
    <!--id不允许修改，使用 disabled 属性禁用修改-->
    <span>ID：</span><input type="text" name="id" th:value="${student.id}" readonly placeholder="新增无需填写此字段"><br>
    <span>姓名：</span><input type="text" name="name" th:value="${student.name}" required><br>
    <span>学号：</span><input type="text" name="stuId" th:value="${student.stuId}" required><br>
    <span>年龄：</span><input type="number" name="age" th:value="${student.age}" required><br>
    <span>性别：</span>
    <label>
        <!-- checked 是单选框的属性，后面的值为 true 时选中当前选项-->
        <input type="radio" name="sex" value="男" th:checked="${student.sex} == '男'">男
    </label>
    <label>
        <input type="radio" name="sex" value="女" th:checked="${student.sex} == '女'">女
    </label>
    <label>
        <input type="radio" name="sex" value="人妖" th:checked="${student.sex} == '人妖'">人妖<br>
    </label>
    <span>班级：</span>
    <select name="className" th:value="${student.className}">
        <!-- selected 是下拉选择框的属性，后面的值为 true 时选中当前选项-->
        <option value="软开1班" th:selected="${student.className} == '软开1班'">软开1班</option>
        <option value="软开2班" th:selected="${student.className} == '软开2班'">软开2班</option>
        <option value="软开3班" th:selected="${student.className} == '软开3班'">软开3班</option>
        <option value="软开4班" th:selected="${student.className} == '软开4班'">软开4班</option>
    </select><br>

    <span>辅导员</span>
    <select name="teacher" th:value="${student.className}">
        <option th:each="teacher : ${teacherList}" th:value="${teacher.id}">[[${teacher.name}]]</option>
    </select><br>

    <span>毕业：</span>
    <label>
        <input type="radio" name="isGraduate" value="1" th:checked="${student.isGraduate} == 1">是
    </label>
    <label>
        <input type="radio" name="isGraduate" value="0" th:checked="${student.isGraduate} == 0">否
    </label><br>
    <input type="submit" value="保存">
</form>
</body>
</html>